home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
bipl.zip
/
PROCS.ZIP
/
DISTANCE.ICN
< prev
next >
Wrap
Text File
|
1992-09-28
|
757b
|
35 lines
############################################################################
#
# File: distance.icn
#
# Subject: Procedure to compute distance in n-dimensional space
#
# Author: Ralph E. Griswold
#
# Date: September 27, 1992
#
###########################################################################
#
# distance(d1, d2, d3, ...) returns the distance between points in n-space
# distances d1, d2, d3, ... from the origin.
#
############################################################################
procedure main()
write(distance(1, 1, 1, 1, 1, 1, 1, 1, 1))
write(distance(2, 2))
write(distance(1))
end
procedure distance(d[])
sum := 0
every sum +:= !d ^ 2
return sqrt(sum)
end